package com.zh.note.huawei.onehundred.斗地主2之顺子;

/**
 * @Author: zhanghuan
 * @date: 2023/9/3 18:25
 * @description: create it
 */

import java.util.*;

public class Main {
    static Map<String, Integer> map = new HashMap<>();
    static char[] card = {'3', '4', '5', '6', '7', '8', '9', '1', 'J', 'Q', 'K', 'A'};

    static void init() {
        map.put("2", 13);
        map.put("3", 0);
        map.put("4", 1);
        map.put("5", 2);
        map.put("6", 3);
        map.put("7", 4);
        map.put("8", 5);
        map.put("9", 6);
        map.put("10", 7);
        map.put("J", 8);
        map.put("Q", 9);
        map.put("K", 10);
        map.put("A", 11);
    }

    static void print(int x, int y) {
        for (int i = x; i < y; ++i) {
            if (i != x) {
                System.out.print(" ");
            }
            System.out.print(card[i]);
        }
        System.out.println();
    }

    public static void main(String[] args) {
        init();
        Scanner scanner = new Scanner(System.in);
        // String str = scanner.nextLine();
        String str = "2 9 J 10 3 4 K A 7 Q A 5 6";
        int[] num = new int[15];
        String[] s = str.split(" ");
        // 转换
        for (String value : s) {
            num[map.get(value)]++;
        }

        boolean ans = false;
        for (int i = 0; i < 12; ++i) {
            int j = i;
            while (j < 12) {
                if (num[j] == 0) {
                    break;
                }
                ++j;
            }
            if (j - i > 4) {
                ans = true;//表示找到了一个
                // 把i~j的值都-1
                for (int k = i; k < j; ++k) {
                    num[k]--;
                }
                print(i, j);
            }
        }
        if (!ans) {
            System.out.println("NO");
        }
    }


}
